const {
  getSiteInclusion,
  addSiteInclusion,
  updateSiteInclusion,
  deleteSiteInclusion,
} = require("../../service/siteInclusion/siteInclusion.service");
const {
  querySuccess,
  addSuccess,
  updateSuccess,
  deleteSuccess,
} = require("../../constant/success.type");
const {
  addError,
  queryError,
  updateError,
  deleteError,
} = require("../../constant/err.type");
class SiteInclusionController {
  async getSiteInclusion(ctx, nuxt) {
    try {
      const db_response = await getSiteInclusion(ctx.request.query);
      querySuccess.result = db_response;
      ctx.body = querySuccess;
    } catch (err) {
      console.log(err);
      ctx.app.emit("error", queryError, ctx);
    }
  }
  async addSiteInclusion(ctx, nuxt) {
    try {
      const db_response = await addSiteInclusion(ctx.request.body);
      addSuccess.result = db_response;
      ctx.body = addSuccess;
    } catch (err) {
      console.log(err);
      ctx.app.emit("error", addError, ctx);
    }
  }
  async updateSiteInclusion(ctx, nuxt) {
    try {
      const db_response = await updateSiteInclusion(ctx.request.body);
      updateSuccess.result = db_response;
      ctx.body = updateSuccess;
    } catch (err) {
      console.log(err);
      ctx.app.emit("error", updateError, ctx);
    }
  }
  async deleteSiteInclusion(ctx, nuxt) {
    try {
      const db_response = await deleteSiteInclusion(ctx.query);
      deleteSuccess.result = db_response;
      ctx.body = deleteSuccess;
    } catch (err) {
      console.log(err);
      ctx.app.emit("error", deleteError, ctx);
    }
  }
}

module.exports = new SiteInclusionController();
